import { defineStore } from "pinia";
import { findList } from "@/api/item";
// import Message from "@/utils/message";

export const useItem = defineStore('Item', {
	state: () => {
		return {
			ItemList: [],
		}
	},
	actions: {
		async getItemFn(isRead = false) {      // 获取信息
			if (isRead || this.ItemList.length == 0) {
				const result = await findList({ page:1,size:99 });
				if (!result) return;
				const { list } = result;
				if(list){
					this.ItemList = list.map((item)=> ({ ...item,checked:false,sorce:'',selectd:false, show:true}));
				}else{
					this.ItemList = [];
				}
			}
			// this.setLogoTitle();
		},
		async resetList() {
			this.ItemList = this.ItemList.map((item)=> ({ ...item,checked:false,sorce:'',selectd:false,show:true }));
		},
	},
	getters: {

	},
	// persist: true
})